#include "Entity.h"
#include "D3d11Utils.h"

Entity::Entity(): mScaling(1.0f), mName("")
{
}

Entity::Entity(const char * name): mScaling(1.0f)
{
}

Entity::~Entity()
{
}

void Entity::Release()
{
	SAFE_RELEASE(mpGraphic);
}

XMFLOAT4X4 Entity::GetWorld()
{
	XMMATRIX scaling = XMMatrixScaling(mScaling, mScaling, mScaling);

	XMVECTOR xmQ = XMLoadFloat3(&mPosition);
	xmQ = XMVectorSetW(xmQ, 1.0f);
	XMVECTOR xmV = XMLoadFloat3(&mUp);
	xmV = XMVectorSetW(xmV, 0.0f);
	XMVECTOR xmW = XMLoadFloat3(&mFront);
	xmW = XMVectorSetW(xmW, 0.0f);
	XMVECTOR xmU = XMVector3Normalize(XMVector3Cross(xmV, xmW));
	xmU = XMVectorSetW(xmU, 0.0f);
	XMMATRIX xmRes(xmU, xmV, xmW, xmQ);
	
	xmRes = XMMatrixMultiply(scaling, xmRes);

	XMFLOAT4X4 res;
	XMStoreFloat4x4(&res, xmRes);

	return res;
}